package com.example.boke.tool;

import java.io.File;
import java.net.URISyntaxException;

/**
 * @author Xdoor
 * @version 1.0
 * @date 2021/10/21 10:40
 */

public class LocalDir
{
    public static void main(String[] args)
    {
        dir();
    }

    public static String dir()
    {
        String path = "";
        try
        {
            File dir = new File(
                    LocalDir.class.getClassLoader().getResource(".").toURI()
            );
            path = dir.getPath().toLowerCase();
            System.out.println(path);
            path = path.substring(0, path.indexOf("\\boke\\") + 5);
            System.out.println(path);
            path = path + "/src/main/resources/upload";
            System.out.println(path);

            /*
            第二种找根目录的代码
            String a = System.getProperty("user.dir");
            System.out.println(a);
            path = a + "/src/main/resources/upload";
            System.out.println(path);
            */

        }
        catch (URISyntaxException e)
        {
            e.printStackTrace();
        }
        return path;
    }
}
